#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include "alp_string.h"

alp_status_t alp_strntoz(size_t *size, const char *s, size_t len)
{
	size_t r = 0;
	for (; len; --len, ++s)
	{
		char ch = *s;
		if (!isdigit(ch))
			return ALP_E_INPUT; //-3
		r = r * 10 + (ch - '0');
	}
	*size = r;
	return 0;
}

void * alp_memdup(const void *p, size_t size)
{
	void *r = malloc(size);
	if (r == 0)
		return 0;
	return memcpy(r, p, size);
}
